package com.health.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.health.R;
import com.health.tablebean.BD_ORGANIZE_EMPLOYEE;

import java.util.List;

/**
 * 下拉菜单
 * Created by John on 2019/4/10.
 */

public class SpinnerAdapter extends BaseAdapter {
    private List<String> list;
    private Context mContext;

    public SpinnerAdapter(Context mContext,List<String> list){
        this.mContext=mContext;
        this.list=list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.ssq_listitem, null);
            vh = new ViewHolder();
            findView(vh, convertView);
            convertView.setTag(R.id.TAG_VIEWHOLDER, vh);
        } else
            vh = (ViewHolder) convertView.getTag(R.id.TAG_VIEWHOLDER);

        setData(vh, convertView, position);

        return convertView;
    }

    /**
     * 赋值
     * @param h
     * @param v
     * @param position
     * @author 王婷婷
     * @date 2015年12月3日 上午10:24:28
     */
    private void setData(ViewHolder h, View v, int position) {
        h.nameText.setText(list.get(position));
    }

    private void findView(ViewHolder h, View v) {
        h.nameText = (TextView) v.findViewById(R.id.tv_ssq);

    }

    private static class ViewHolder {
        TextView nameText;
    }
}
